<?php
namespace app\index\controller;

use think\Controller;
use think\View;
use Jssdk\JSSDK;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/1
 * Time: 15:14
 */
class Wallet extends CheckMember{
    /*钱包首页*/
    public function index(){
        $data = $this->local_invoke_api('get_member_info', ['member_id' => session('member_id')]);
        $this->assign('data', $data['data']);
        return view();
    }
    /*充值*/
    public function bank_list(){
        return view();
    }

    /**
     * 添加银行卡
     * @return \think\response\Json|\think\response\View
     */
    public function add_bank() {
        if (request()->isAjax()) {
            $param = input('param.');
            $param['member_id'] = session('member_id');
            $data = $this->local_invoke_api('save_bank', $param);
            return json($data);
        } else {
            return view();
        }
    }

    /*提现*/
    public function withdraw(){
        $data = $this->local_invoke_api('get_member_info', ['member_id' => session('member_id')]);
        $this->assign('data', $data['data']);
        return view();
    }

    /**
     * 用户提现申请
     * @return \think\response\Json
     */
    public function withdraw_apply_for() {
        $param = input('param.');
        $param['member_id'] = session('member_id');
        $data = $this->local_invoke_api('withdraw_apply_for', $param);
        return json($data);
    }

    /*交易明细*/
    public function details(){
        $data = $this->local_invoke_api('get_member_bill', ['member_id' => session('member_id')]);
        $this->assign('data', $data['data']);
        return view();
    }
    /*交易详情*/
    public function trading(){
        $param = input('param.');
        $param['member_id'] = session('member_id');
        $data = $this->local_invoke_api('get_member_bill_info', $param);
        $this->assign('data', $data['data']);
        return view();
    }
}